﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlServerCe;
using System.Windows.Forms;
using System.Data;

namespace RCSnake
	{
	class Tools
		{
		/// <summary>
		/// Retourne le nombre de lignes d'une table
		/// </summary>
		/// <param name="connection"></param>
		/// <param name="nameTable"></param>
		/// <returns>Le nombre de lignes d'une table</returns>
		static public int getNbLines(SqlCeConnection connection, String nameTable)
			{
			String query = "select * from " + nameTable;

			SqlCeCommand cmd = new SqlCeCommand();
			cmd.Connection = connection;
			cmd.CommandText = query;

			DataSet ds = new DataSet();
			SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
			da.Fill(ds, nameTable);

			DataTable table = ds.Tables[nameTable];

			return table.Rows.Count;
			}
		}
	}
